/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__l7_del.c                                        */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/31 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <protobuf-c/protobuf-c.h>

#include "../../comm/frcmd_parse_detail.h"
#include "../../comm/client.pb-c.h"
#include "../../comm/frcmd_parse.h"
#include "../../comm/apm.pb-c.h"
#include "../../comm/frcmd_client.h"
#include "../../comm/frcomm.h"
#include "../../comm/frmem.h"
#include "../../comm/frsutl.h"
#include "../../comm/apmtest_cunit.h"

static int __suite_init(void)
{
	return 0;
}

static int __suite_cleanup(void)
{
	return 0;
}
extern int g_i_port;
extern char* g_p_server;

int __l7_del(char *ip_proto, char *ip_addr, char *port);

void case1(void)
{
    int i_ret = 0;
    char *ip_proto = NULL;
    char *ip_addr = NULL;
    char *port = NULL;

    g_i_port = 65535;
    g_p_server = "127.0.0.1";
    ip_proto = frmalloc(strlen("tcp") + 1);
    snprintf(ip_proto,strlen("tcp") + 1,"%s", "tcp");

    ip_addr = frmalloc(strlen("192.168.1.1") + 1);
    snprintf(ip_addr,strlen("192.168.1.1") + 1,"%s", "192.168.1.1");

    port = frmalloc(strlen("6356") + 1);
    snprintf(port,strlen("6356") + 1,"%s", "6356");

    i_ret = __l7_del(ip_proto, ip_addr, port);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    frfree(ip_proto);
    frfree(ip_addr);
    frfree(port);
    return;
}


int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t__l7_del 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}


    //增加测试用例
   	CU_add_test(pSuite, "case1", case1);

    return 0;

}

int main(int argc, char **argv)
{
    frmem_init();
    run_cunit(add_suite);
    frshow_leak();
    frmem_destroy();
    return 0;
}